import random


class Color:
    light_yellow = '#F9F5ED'  # 略淡黄色
    light_white = '#F5F5F5'  # 略淡白色
    light_green = "#98FB98"
    default_bg = 'white'  # 默认背景色
    default_fg = 'black'  # 默认字体颜色
    red = "red"  # 红色
    zebra1 = '#ADD6F1'  # 斑马配色方案 单数时
    zebra2 = '#D5E9F9'  # 斑马配色方案 双数时
    zebra3 = '#A1C0CB'  # 斑马配色方案 选中时
    cutkinter = '#DEDEDE'

    duibi_yellow = "#EEB905"
    duibi_blue = "#0254E3"


class RandomPolicy:
    """
    参数:
        {
            value: english-chinese对
            count: 最多取几个
            _type: 类型
        }

    """

    @staticmethod
    def All(config):
        return config.get('value')

    @staticmethod
    def getRandomCounter(config):
        list = config.get("value")
        return random.choices(list, k=int(config.get('count')))

    @staticmethod
    def loadByConfig(config, c_e):
        mapper = {}
        mapper['_type'] = config.getValue("WordConfig", "policy")
        mapper['count'] = config.getValue("WordConfig", "count")
        mapper['value'] = c_e

        if mapper['_type'] == "顺序且全部":
            return RandomPolicy.All(mapper)
        elif mapper['_type'] == "打乱":
            return RandomPolicy.getRandomCounter(mapper)
        else:
            return [("Config文件格式错误","None")]
